package com.app.utils.impl.labour;

import android.annotation.SuppressLint;
import android.os.Build;

import androidx.annotation.RequiresApi;

import com.app.utils.impl.IConsole;
import com.app.utils.impl.Strategy;
import com.zndroid.utils.XUtils;
import com.zndroid.utils.impl.AssetsUtil;

import java.io.File;

/**
 * Created by lzy on 2022/2/15.
 */
public class AssetsUtilStrategy extends Strategy {

    public AssetsUtilStrategy(IConsole iConsole) {
        super(iConsole);
    }

    @RequiresApi(api = Build.VERSION_CODES.R)
    @SuppressLint("MissingPermission")
    @Override
    public void doing() {
        AssetsUtil util = XUtils.create().assetsUtil();
        iConsole.console("readFromAssets(\"test\\test.txt\")", util.readFromAssets(XUtils.getContext(), "test/test.txt"));
        iConsole.console("copyFileFromAssets", "目标文件路径：/data/data/com.app.utils/files/test2.txt");util.copyFileFromAssets(XUtils.getContext(), "test/test.txt", new File("/data/data/com.app.utils/files/test2.txt"));
        iConsole.console("getFilesFromAssets", util.getFilesFromAssets(XUtils.getContext(), "test").length + "个");
        iConsole.console("putAssetsToSDCard", "目标文件路径：/sdcard【权限请手动允许】"); util.putAssetsToSDCard(XUtils.getContext(), "test/test.txt", "/sdcard");
    }
}
